﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service.BusinessLayer.Entities;
using Service.DataAccess.DataAccessHelper;
using System.Data.SqlClient;
using System.Data;

namespace Service.DataAccess.DataAccessLogic
{
    public class SoNhap_DA
    {
        public void them(SoNhap sn)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[4];
            par[0] = new SqlParameter("@masn", sn.Masn);
            par[1] = new SqlParameter("@makh", sn.Makh);
            par[2] = new SqlParameter("@manv", sn.Manv);
            par[3] = new SqlParameter("@ngaynhap", sn.Ngaynhap);
            help.InsertQuery("sp_sonhap_them", par);

        }
        public void sua(SoNhap sn)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[4];
            par[0] = new SqlParameter("@masn", sn.Masn);
            par[1] = new SqlParameter("@makh", sn.Manv);
            par[2] = new SqlParameter("@manv", sn.Makh);
            par[3] = new SqlParameter("@ngaynhap", sn.Ngaynhap);
            help.UpdateQuery("sp_sonhap_sua", par);
        }
        public void xoa(string masn)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@masn", masn);
            help.DeleteQuery("sp_sonhap_xoa", par);
        }
        public DataSet LayDS()
        {
            Helper help = new Helper();
            DataSet ds = new DataSet();
            ds=help.SelectQuery("sp_sonhap_layds");
            return ds;
        }
        public DataSet LayDS_TheoNgayNhap(DateTime ngaynhap)
        {
            Helper help = new Helper();
            DataSet ds = new DataSet();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@ngaynhap", ngaynhap);
            ds = help.SelectQuery("sp_sonhap_layds_ngaynhap",par);
            return ds;
        }
        public DataSet LayDSCTSoNhap_Theo_MaSN(string MaSN)
        {
            Helper help = new Helper();
            DataSet ds = new DataSet();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@MaSN", MaSN);
            ds = help.SelectQuery("sp_DSCTSoNhap_Theo_MaSN", par);
            return ds;
        }
        public DataSet LayDS_SoNhapChuaGiao_TheoMaKH(int MaKH)
        {
            Helper help = new Helper();
            DataSet ds = new DataSet();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@MaKH", MaKH);
            ds = help.SelectQuery("sp_DSNhap_ChuaGiao_TheoMaKH", par);
            return ds;
        }
    }
}
